package com.zwd.cases.demo.gof23.strategy.cashstrategy;

/**
 * @Description 上下文
 * @Author zhengwd
 * @Date 2023/4/12 20:40
 **/
public class CashContent {

    CashSuper cashSuper = null;

    public CashContent(String type) {
        switch (type) {
            case "正常收费":
                this.cashSuper = new CashNormal();
                break;
            case "打5折":
                this.cashSuper = new CashRebate(0.5);
                break;
            case "打8折":
                this.cashSuper = new CashRebate(0.8);
                break;
            case "满300返100":
                this.cashSuper = new CashReturn(300, 100);
                break;
            case "满500返200":
                this.cashSuper = new CashReturn(500, 200);
                break;
        }
    }

    /**
     * 上下文接口方法
     */
    public double getResult(double money) {
        return cashSuper.acceptCash(money);
    }
}
